{% comment %}
#    Copyright 2012 New Mexico EPSCoR
#
#    This file is part of Teacher's P.E.T.
#
#    Teacher's P.E.T. is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    Teacher's P.E.T. is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with Teacher's P.E.T..  If not, see <http://www.gnu.org/licenses/>.
{% endcomment %}

<tr class="forum-entries-row forum-entries-header-row">
	<th colspan="100%" class="forum-entries-entry-info">
		{% if entry %}
		<a name="post{{entry.entry_number}}">
			<span class="forum-entries-creation-date">{{entry.creation_date|date:"D, d M Y P "}}</span>
			<span class="forum-entries-entry-number">#{{entry.entry_number}}</span>
		</a>
		{% endif %}
	</th>
</tr>
<tr class="forum-entries-row forum-entries-mainrow">
	<td class="forum-entries-avatar">
		{% if EntryForm %}
			{% with User=users|getitem:request.user.username%}
				{{User.user.username}}
				{% if not entry.flagged_as_deleted %}
					<br><img src="{% if User.avatar %}{{User.avatar}}{% else %}{{STATIC_URL}}images/BlankAvatar.png{% endif %}" height="75"><br>
				{% endif %}
				{% if not ban or ban.message_ban < ban.BAN_NEW_MESSAGES %}
					<a href="{% course_url forum_send_message %}?recipient={{User.user.username}}"><img src="{{STATIC_URL}}images/compose.png" title="Send this user a message" height="25"></a>
				{% endif %}
			{% endwith %}
		{% else %}
			{% with User=users|getitem:entry.author.user.username%}
				{{User.user.username}}
				{% if not entry.flagged_as_deleted %}
					<br><img src="{% if User.avatar %}{{User.avatar}}{% else %}{{STATIC_URL}}images/BlankAvatar.png{% endif %}" height="75"><br>
				{% endif %}
				{% if not ban or ban.message_ban < ban.BAN_NEW_MESSAGES %}
					<a href="{% course_url forum_send_message %}?recipient={{User.user.username}}"><img src="{{STATIC_URL}}images/compose.png" title="Send this user a message" height="25"></a>
				{% endif %}
			{% endwith %}
		{% endif %}
	</td>
	<td class="forum-entries-entry">
		{% if entry.flagged_as_deleted %}
			<div class="forum-entries-entry-deleted"><p>This post has been deleted</p></div>
		{% else %}
			<div class="forum-entries-entry-content">
				<span
				{% if entry.author.status == "INSTRUCTOR" %}class="forum-entries-entry-content-instructor"{% endif %}
				{% if entry.author.status == "ASSISTANT" %}class="forum-entries-entry-content-assistant"{% endif %}
				>
					{% if EntryForm %}
						{{EntryForm.entry}}
						{% for error in EntryForm.entry.errors %}<br><span class="error">{{error}}</span>{% endfor %}
					{% else %}
						{% render entry.entry %}
					{% endif %}
				</span>
				<div style="clear: both;"></div>
				<span class="forum-entries-entry-files">
					<ul>
						{% if not hide_files %}
							{% for file in Files %}
								<li>
									<a href="{% course_url forum_download_attachment thread_id=TheThread.id entry_number=entry.entry_number filename=file.filename %}" target="_blank">
										<img src="{{STATIC_URL}}images/files/{{file.icon}}" height="25"> {{file.title}}{% if file.extension %}.{{file.extension}}{% endif %}
									</a>{% if file.description %} - {{file.description}}{% endif %}
									{% if not hide_delete_attachment %}
									<a href="{% course_url forum_delete_attachment thread_id=TheThread.id entry_number=entry.entry_number file_id=file.id %}" class="forum-entries-button forum-entries-delete-attachment">x</a>
									{% endif %}
								</li><br>
							{% endfor %}
						{% endif %}
					</ul>
				</span>
				<div style="clear: both;"></div>
			</div>
			<div class="forum-entries-entry-options">
				{% if not TheThread.is_locked and not entry.flagged_as_deleted and not hide_editing %}
					{% if not ban or ban.forum_ban < ban.BAN_POSTS %}
						{% if entry.author.user == request.user %}
							<a class="forum-entries-button forum-entries-edit-button" href="{% course_url forum_edit_entry thread_id=TheThread.id entry_number=entry.entry_number %}">Edit Post</a>
						{% endif %}
					{% endif %}
				{% endif %}

				{% if not hide_editing %}
				<span class="forum-entries-last-edit">
				{% if entry and entry.edited_date != entry.creation_date %}
						Edited on {{entry.edited_date|date:"r"}}
				{% endif %}
				</span>
				{% endif %}
				
				{% if entry and not entry.liked and entry.author != CourseUser.course_participant %}
					<a class="forum-entries-like" href="{% course_url forum_like_entry thread_id=TheThread.id entry_number=entry.entry_number %}" title="Thank this user for this post">
					<img src="{{STATIC_URL}}images/thumbs_up.png" height="25">
					</a>
				{% endif %}
				
				{% if not TheThread.is_locked and not hide_editing %}
					{% if not ban or ban.forum_ban < ban.BAN_POSTS %}
					<a class="forum-entries-quote-entry" href="{% course_url forum_create_quoted_entry thread_id=entry.thread.id quote_entry_number=entry.entry_number %}"><img src="{{STATIC_URL}}images/speech.png" height="25" title="Reply to this entry"></a>
					{% endif %}
				{% else %}
				<img class="forum-entries-quote-entry" src="" height="25">
				{% endif %}
				
				{% if entry and entry.flagged_for_moderator %}
					<img class="forum-entries-flag" src="{{STATIC_URL}}images/thumbs_down_done.png" height="25" title="This post has been flagged for moderator review">
				{% else %}
					{% if entry and entry.author != CourseUser.course_participant %}
						<a class="forum-entries-flag" href="{% course_url forum_flag_entry thread_id=TheThread.id entry_number=entry.entry_number %}" title="Flag this post for moderator review for inappropriate content">
							<img src="{{STATIC_URL}}images/thumbs_down.png" height="25">
						</a>
					{% endif %}
				{% endif %}
			</div>
		{% endif %}
	</td>
</tr>
{% if entry.likes.count > 0 and not hide_likes %}
<tr class="forum-entries-row forum-entries-thanks-row">
	<td colspan="100%">The following users thank {{entry.author.user.username}} for this post: 
	{% for like in entry.likes.all %}
		{{like.course_participant.user.username}}{% if not forloop.last %}, {% endif %}
	{% endfor %}
	</td>
</tr>
{% endif %}
<tr class="forum-entries-spacer-row"><td class="forum-entries-spacer"></td></tr>
